<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Browser extends CI_Controller
{
    public function check_browser()
    {
        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.0')) {
            echo '<meta charset="UTF-8" />';
            echo '请使用Google Chrome浏览器 或 IE7以上浏览器';
            exit();
        }
        
        //推荐人，通用
        $username = $this->input->get('username');
        if (!empty($username) && $username != 'bz_teck') {
            $isUser = $this->checkExistUser($username);
            if ($isUser) {
                delete_cookie('true_user');
                set_cookie('true_user', $username, 43250); //'.zxkj918.com'为第四个参数
            } else {
                delete_cookie('true_user');
            }
        }
    }
    
    public function checkExistUser($username)
    {
        if (isset($this->user)) { //是否存在某个对象
            $isExist = $this->user->validateExistUser($username);
        } else {
            $this->load->model('user_model', 'user');
            $isExist = $this->user->validateExistUser($username);
        }
        return $isExist;
    }
}
